import time
from time import sleep

from apscheduler.schedulers.background import BackgroundScheduler


def job():
    print('定时任务执行了')

def cron():
    scheduler = BackgroundScheduler()
    scheduler.add_job(job, 'interval', seconds=5)  # 每 5 秒钟执行一次
    scheduler.start()
    while True:
        sleep(1)

cron()


